package ttc.mbackup.newsmsbackup;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;


public class SMSQuery extends Activity {
	private static String SMS_URI_SMS_ALL="content://sms/";
	private static String SMS_URI_SMS_INBOX="content://sms/inbox";
	private static String SMS_URI_SMS_OUTBOX="content://sms/outbox";
	private Context context;
	public SMSQuery()
	{
		super();
		context=this.context;
	}
	public Cursor getAllSMS()
	{	
		Uri uriSMS=Uri.parse("content://sms/");
		
		Cursor cursorSMS=context.getContentResolver().query(uriSMS, null, null, null, null);
		/*try
		{
			 cursorSMS= getContentResolver().query(uriSMS, null, null, null, null);
		}	
		catch(Exception ex)
		{
			Toast.makeText(this, ex.getMessage(), Toast.LENGTH_SHORT);
		}
		if(cursorSMS.getCount()>0)
			return cursorSMS;
		else 
			return null;*/
		return cursorSMS;
	}
	public Cursor getInboxSMS()
	{
		Uri smsUri= Uri.parse("content://sms/inbox");
	
		Cursor cursorInboxSMS = context.getContentResolver().query(smsUri, null, null, null, null);
		return cursorInboxSMS;
	}

	public Cursor getOutboxSMS()
	{
		Uri smsUri= Uri.parse(SMS_URI_SMS_OUTBOX);
		Cursor cursorOutboxSMS = context.getContentResolver().query(smsUri, null, null, null, null);
		return cursorOutboxSMS;
	}
	public void insertSMS(ContentValues values)
	{
		Uri smsUri= Uri.parse(SMS_URI_SMS_ALL);
		context.getContentResolver().insert(smsUri, values);
	
	}
	
}
